package MeiJuLei;

/**
 * 枚举类的使用
 * 1.当类的对象是有限个，确定的个数，我们称此类为枚举类
 * 2.当需要定义一组常量时，强烈建议使用枚举类
 *
 * 定义枚举类
 * 方式一：自定义  jdk5.0之前
 * 方式二：enum关键字 jdk5.0之后
 */
public class Demo1 {
    public static void main(String[] args) {
        Season1 spring = Season1.SPRING;
        System.out.println(spring);
    }
}

class Season1{
    //1.声明对象的属性:private final 修饰
    private final String seasonName;
    private final String seasonDesc;

    //2.私有的构造器
    private Season1(String seasonName,String seasonDesc){
        this.seasonName = seasonName;
        this.seasonDesc = seasonDesc;
    }
    //3.提供当前枚举类的多个对象public static final
    public static final Season1 SPRING = new Season1("春天","春暖花开");
    public static final Season1 SUMMER = new Season1("夏天","炎炎夏日");
    public static final Season1 AUTUMN = new Season1("秋天","秋高气爽");
    public static final Season1 WINTER= new Season1("冬天","寒风凛冽");

    //4.外界获取枚举类的属性

    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }
    //5.重写toString方法

    @Override
    public String toString() {
        return "Season1{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }
}